<?php
/**
 *  Display Any Button (mod_anybutton) Module Entry Point
 *
 * @link http://www.MikeMillsConsulting.com
 * @license        GNU/GPL, see LICENSE.php
 * mod_anybutton is free software. This version may have been modified pursuant
 * to the GNU General Public License, and as distributed it includes or
 * is derivative of works licensed under the GNU General Public License or
 * other free or open source software licenses.
 * 
 * Description:
 *
 * Displays an arbitrary button (for example, your LinkedIn profile.)  You have
 * to configure the source for your button within the module configuration admin
 * panel in Joomla.
 * 
 * Example buttons can be found on LinkedIn.com:  When viewing your profile
 * (under "My Profile"), click on the 'Promote your profile' link.
 * 
 * Note that the buttons are just html code snippets, and so can really be
 * anything you want.
 *
 * If you need SSL (because loading remote images from a non-SSL host will
 * create warning messages in client browser windows), then modify the button
 * source such that any <img> reference to 'http' is replaced with 'https'.
 * Save this source under the button_src_ssl parameter.
 *
 * If both parameters are set, this module will will choose the appropriate
 * parameter depending on whether the current base URL is https or not.
 *
 * If you do _not_ define button_src_ssl, then no button will be
 * displayed when https is used to access your site.
 *
 * Similarly, if you do _not_ define button_src (i.e., non-ssl),
 * then no button will be displayed when (non-ssl) http is used to access your
 * site.
 *
 * So: Define both parameters in order to get the button to display for both
 * ssl and non-ssl access.
 *
 * Following are examples for my LinkedIn profile:
 *
 * First, here's the non-SSL button source:

<a href="http://www.linkedin.com/in/mikemillsconsulting" ><img src="http://www.linkedin.com/img/webpromo/btn_viewmy_160x33.gif" width="160" height="33" border="0" alt="View Mike Mills's profile on LinkedIn"></a>

  * Next, here's the SSL button source.  Note that the only change is that the
  * 'http' inside the <img> tag has been changed to 'https':

<a href="http://www.linkedin.com/in/mikemillsconsulting" ><img src="https://www.linkedin.com/img/webpromo/btn_viewmy_160x33.gif" width="160" height="33" border="0" alt="View Mike Mills's profile on LinkedIn"></a>

 * Notice that the <a href=...> does not need to be changed to https, as this is
 * just a hyperlink that doesn't do anything until the user clicks on it.  But
 * the <img> tag, on the other hand, loads a remote image from LinkedIn's servers.
 * To avoid the "some items are non-secure on this page" type of browser warning,
 * we need to specify an SSL URL for any remote images when SSL is being used to
 * access our website.
 *
 * The code below automatically detects whether the client is accessing our site
 * with SSL, and then uses the appropriate button source accordingly.
 *
 */

// no direct access
defined( '_JEXEC' ) or die( 'Restricted access' );

$params->def('button_src', ''); // Set default to be empty string.
$params->def('button_src_ssl', ''); // Set default to be empty string.

$RURL = JURI::base();  //Get base URL - we check if SSL is being used below.

$button_src = '';

if(substr($RURL, 0, 5) == 'https')
	$button_src = $params->get('button_src_ssl');
else
	$button_src = $params->get('button_src');

if($button_src != '')
	echo $button_src;

?>
